package Thread;

//使用匿名内部类 来完成方式1和方式2 创建线程
public class CreateThread3 {
    public static void main(String[] args) {

        //方式一
        Thread thread1=new Thread(){
          public void run(){
              for (int i = 0; i < 1000; i++) {
                  System.out.println("你是谁啊");
              }
          }
        };

        thread1.start();

        //方式二
        Runnable runnable=new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println("你猜我是谁");
                }
            }
        };
        Thread thread=new Thread(runnable);
        thread.start();



        //第二种可以改成

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println("你猜我是谁2");
                }
            }
        }).start();



    }
}
